<div class="am-cf am-padding">
    <div class="am-fl am-cf">
        <strong class="am-text-primary am-text-lg">首页</strong> /
        <small>资讯管理</small> /
        <small>新增资讯</small> 
    </div>
</div>

<!-- <div class="am-padding">
    <a class="am-btn am-btn-default am-btn-xs am-text-secondary" href="{:U('newsAdd')}">新增资讯</a>
</div> -->

<div class="am-g">
    <div class="am-u-sm-12">
        <form enctype="multipart/form-data" id="news-form" class="am-form" action="{:U('newsAdd')}" method="POST">
            <div class="am-g am-margin-top-sm">
                <div class="am-u-sm-2 am-text-right">
                    资讯标题
                </div>
                <div class="am-u-sm-4 am-u-end">
                <input type="text" class="am-input-sm" name="title">
                </div>
            </div>

            <div class="am-g am-margin-top-sm">
                <div class="am-u-sm-2 am-text-right">
                    资讯类别
                </div>
                <div class="am-u-sm-4 am-u-end">
                    <select name="type">
                        <foreach name="newstype" item="o">
                            <option value="{$o.id}">{$o.name}</option>
                        </foreach>
                    </select>
                </div>
            </div>

            <div class="am-g am-margin-top-sm">
                <div class="am-u-sm-2 am-text-right">
                    资讯简介
                </div>
                <div class="am-u-sm-4 am-u-end">
                    <input type="text" class="am-input-sm" name="discrition">
                </div>
            </div>

            <div class="am-g am-margin-top-sm">
                <div class="am-u-sm-2 am-text-right">
                    标题图
                </div>
                <div class="am-u-sm-4 am-u-end">
                    <input type="file" name="pic">
                </div>
            </div>

            <div class="am-g am-margin-top-sm">
                <div class="am-u-sm-2 am-text-right">
                    资讯内容
                </div>
                <div class="am-u-sm-4 am-u-end">
                    <input id="content" type="hidden" name="content" >
                    <textarea id="container" style="width: 500px; height: 300px;"></textarea>
                </div>
            </div>
            <div class="am-g am-margin-top-sm">
                <div class="am-u-sm-2 am-text-right">
                    &nbsp;
                </div>
                <div class="am-u-sm-4 am-u-end">
                    <a id="sub" class="am-btn am-btn-default am-btn-xs am-text-secondary">提交</a>
                    <a class="am-btn am-btn-default am-btn-xs am-text-danger" href="{:U('news')}">取消</a>
                </div>
            </div>
        </form>

    </div>
</div>

<script type="text/javascript" charset="utf-8">
    window.UEDITOR_HOME_URL = "__PUBLIC__/Ueditor/";
    var editor;
    $(function () {
        editor = UE.getEditor('container', {
            toolbars: [
                [
                    'undo', 'redo', '|', 
                    'bold', 'italic', 'underline', 'fontborder', 'strikethrough',
                    'superscript', 'subscript', 'removeformat', 'autotypeset', 'blockquote', 'pasteplain', '|', 
                    'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|', 
                    'rowspacingtop', 'rowspacingbottom', 'lineheight', '|', 
                    'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|', 
                    'directionalityltr', 'directionalityrtl', 'indent', '|',
                    'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 
                    'touppercase', 'tolowercase', '|', 
                    'link', 'unlink','anchor', '|', 
                    'imagenone', 'imageleft', 'imageright', 'imagecenter', '|', 
                    'simpleupload', '|', 
                    'drafts',
                ]
            ],
            initialFrameHeight: 500,
            initialFrameWidth: 1100,
            serverUrl: "{:U(MODULE_NAME.'/Index/save_info')}"
        });

        $('#sub').click(function () {
            var html = editor.getContent();
            $('#content').val(html);
            console.log('html:', html);
            var f =  $('#news-form')[0]
            f.submit();
        })
    });
</script>